//package com.hadwinling.lot.demo;
//
//import org.apache.iotdb.tsfile.read.ReadOnlyTsFile;
//import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
//import org.apache.iotdb.tsfile.read.common.Path;
//import org.apache.iotdb.tsfile.read.expression.IExpression;
//import org.apache.iotdb.tsfile.read.expression.QueryExpression;
//import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
//
//import java.io.IOException;
//import java.util.ArrayList;
//
///**
// * @description:
// * @author: hadwinling
// * @time: 2021/2/6 上午9:28
// */
//public class TsFileRead {
//    private static void queryAndPrint(ArrayList<Path> paths, ReadOnlyTsFile readTsFile, IExpression statement)
//            throws IOException {
//        QueryExpression queryExpression = QueryExpression.create(paths, statement);
//        QueryDataSet queryDataSet = readTsFile.query(queryExpression);
//        while (queryDataSet.hasNext()) {
//            System.out.println(queryDataSet.next());
//        }
//        System.out.println("------------");
//    }
//
//    public static void main(String[] args) throws IOException {
//
//        // file path
//        String path = "/home/hadoop/下载/apache-iotdb-0.11.2-bin/apache-iotdb-0.11.2/data/data/sequence/root.ln/0/1612442021131-2-0.tsfile";
//
//        // create reader and get the readTsFile interface
//        TsFileSequenceReader reader = new TsFileSequenceReader(path);
//        ReadOnlyTsFile readTsFile = new ReadOnlyTsFile(reader);
//        // use these paths(all sensors) for all the queries
//        ArrayList<Path> paths = new ArrayList<>();
//        paths.add(new Path("device_1.sensor_1"));
//        paths.add(new Path("device_1.sensor_2"));
//        paths.add(new Path("device_1.sensor_3"));
//
//        // no query statement
//        queryAndPrint(paths, readTsFile, null);
//
//        //close the reader when you left
//        reader.close();
//    }
//}
